//
//  ViewController.m
//  5-24
//
//  Created by 王成龙 on 16/5/24.
//  Copyright © 2016年 wcl. All rights reserved.
//

#import "ViewController.h"
#import "TwoViewController.h"


@interface ViewController ()
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.navigationItem.title=@"么么哒的ip6sp";
    self.view.backgroundColor = [UIColor redColor];//主页面背景色
//    self.tableView.bounces = @"NO" ;
    self.refreshControl = [UIRefreshControl new];//刷新的功能
    self.refreshControl.tintColor = [UIColor greenColor];//刷新圆圈的颜色
    
    self.refreshControl.attributedTitle=[[NSAttributedString alloc] initWithString:@"刷新中" attributes: @{NSForegroundColorAttributeName:[UIColor whiteColor]}];//刷新字体的颜色
    
//    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"+" style:UIBarButtonItemStylePlain target:self action:@selector(onClick:)];
    
    //修改右上角的图标
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCamera target:self action:@selector(onClick:)];
    
    //修改导航文字变图片
    UIImageView * iv = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"5"]];
    self.navigationItem.titleView = iv;
}

//刷新
-(void)onClick:(id)sender
{
    [self.refreshControl endRefreshing];
}

//一行的函数
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 5;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell * call = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil];
    //添加图片
    NSString * imgName = [NSString stringWithFormat:@"%d",indexPath.row +1];
    call.imageView.image = [UIImage imageNamed:imgName];
    //图片变圆的
    call.imageView.layer.cornerRadius = 18;
    
    call.textLabel.text =@"通讯录";
    //可以改每一行的颜色
    //call.backgroundColor =[UIColor colorWithRed:2*indexPath.row/255.0 green:3*indexPath.row/9000.0 blue:5*indexPath.row/255.0 alpha:1];
    call.accessoryType =UITableViewCellAccessoryDisclosureIndicator;//后面箭头
    return call;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    TwoViewController * con = [TwoViewController new];
    [self.navigationController pushViewController:con animated:YES];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
